home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Memory / Stacks / FiniteStack.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  575 b   |  36 lines  |  [TEXT/CWIE]

  1. // FiniteStack.h
  2.  
  3. #ifndef FiniteStack_h
  4. #define FiniteStack_h
  5.  
  6. #ifndef FiniteStackBase_h
  7. #include "FiniteStackBase.h"
  8. #endif
  9. #ifndef AlignedBlock_h
  10. #include "AlignedBlock.h"
  11. #endif
  12. #ifndef Assert_h
  13. #include "Assert.h"
  14. #endif
  15.  
  16. template < class Element, uint32 size >
  17. class FiniteStack: public FiniteStackBase
  18.   {
  19.     private:
  20.         AlignedBlock< size * sizeof( Element ) > space;
  21.     
  22.     public:
  23.         FiniteStack()
  24.           : FiniteStackBase( space, size, sizeof( Element ) )
  25.           {}
  26.         
  27.         void Delete( Element *p )
  28.           {
  29.             Assert( p != 0 );
  30.             p->~Element();
  31.             Release( p );
  32.           }    
  33.   };
  34.  
  35. #endif
  36.